package tr.helper.service;

import org.apache.commons.lang3.StringUtils;

/**
 * tr-service
 *
 * @author MrYe
 * @date 2022-01-19 20:56
 */
public class LoginErrorException extends RuntimeException {

    protected Integer code;
    protected String message;

    public LoginErrorException(String format, Object... objects) {
        formatMessage(format, objects);
    }

    private static String formatMessage(String format, Object[] objects) {
        final String formatStr = StringUtils.replace(format, "{}", "%s");
        return String.format(formatStr, objects);
    }

    public LoginErrorException(String format, Throwable throwable, Object... objects) {
        super(formatMessage(format, objects), throwable);
        this.message = formatMessage(format, objects);
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

}
